package com.shuoyue.ycgk.views.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Handler;
import android.text.Html;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.CheckBox;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.shuoyue.ycgk.R;
import com.shuoyue.ycgk.appcatch.SPUtils;


/**
 * 带确认取消按钮的Dialog
 * Created by Forty'7 on 2019/6/17.
 */

public class QuesSetBackDialog extends Dialog {
    private Context mContext;
    private TextView tvCancel;
    private TextView tvOk;
    private CheckBox checkBox;

    public QuesSetBackDialog(@NonNull Context context) {
        super(context, R.style.dialog);
        this.mContext = context;
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.dialog_ques_set_back);
        getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        tvCancel = findViewById(R.id.tv_cancel);
        tvOk = findViewById(R.id.tv_ok);
        checkBox = findViewById(R.id.check);

        tvCancel.setOnClickListener(v -> dismiss());

        tvOk.setOnClickListener(v -> {
            if (checkBox.isChecked()) {
                SPUtils.setPrefBoolean(mContext, "isShowSetBackDialog", false);
            }
            if (okLisenter != null) {
                okLisenter.ok(checkBox.isChecked());
            }
            dismiss();
        });


    }

    public void setOkLisenter(OkLisenter okLisenter) {
        this.okLisenter = okLisenter;
    }

    OkLisenter okLisenter;

    public interface OkLisenter {
        void ok(boolean isChecked);
    }
}
